package com.woniu.common.vo;

import lombok.Data;

import java.util.HashMap;

@Data
public class AjaxResult extends HashMap<String, Object> {
    private static final Integer SUCCESS = 200;
    private static final Integer ERROR = 500;
    private static final String CODE = "code";
    private static final String MSG = "msg";
    private static final String DATA = "data";
    private Integer total;
    public AjaxResult(Integer code, String msg, Object data) {
        this.put(CODE, code);
        this.put(MSG, msg);
        this.put(DATA, data);

    }
    public AjaxResult(Integer code, String msg, Object data, Integer total) {
        this.put(CODE, code);
        this.put(MSG, msg);
        this.put(DATA, data);
        this.total = total;
    }

    public AjaxResult() {
    }

    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(SUCCESS, msg, data);
    }
    public static AjaxResult success(String msg, Object data,Integer total) {
        return new AjaxResult(SUCCESS, msg, data,total);
    }
    public static AjaxResult success(String msg) {
        return new AjaxResult(SUCCESS, msg, null);
    }
    public static AjaxResult error(String msg) {
        return new AjaxResult(ERROR, msg, null);
    }
    public static AjaxResult error() {
        return new AjaxResult();
    }
}